package com.whcoding.druid.monitor.controller;


import com.alibaba.druid.stat.DruidStatManagerFacade;
import com.whcoding.druid.monitor.pojo.OrmDeptVO;
import com.whcoding.druid.monitor.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Sanilthink
 */
@RestController
@RequestMapping("/dept/")
public class DeptController {

	@Autowired
	private DeptService deptService;

	/**
	 * @param id
	 * @return
	 */
	@GetMapping("queryDeptById")
	public OrmDeptVO queryDeptById(@RequestParam("id") Long id) {
		return deptService.queryDeptById(id);
	}

	/**
	 * 查询全部数据
	 *
	 * @return
	 */
	@GetMapping("queryAllDept")
	public List<OrmDeptVO> queryAllDept() {
		return deptService.queryAllDept();
	}

	@GetMapping("/druid")
	public Object druidStat() {
		// 获取数据源的监控数据
		return DruidStatManagerFacade.getInstance().getDataSourceStatDataList();
	}
}
